<template>
	<view class="container-set">
		<view class="bgc">
			<image src="@/static/imgbgc.png" mode=""></image>
		</view>
		<view class="main">
			<view class="list-cell b-b m-t" @click="navTo('./userInfo')" hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">{{$t('user.name10')}}</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
			<view class="list-cell b-b" @click="navTo('/pageA/setList/setList')" hover-class="cell-hover"
				:hover-stay-time="50">
				<text class="cell-tit">{{$t('user.name11')}}</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
			<!-- #ifdef APP-PLUS -->
			<!-- <view class="list-cell  b-b " hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">云算能</text>
				<text class="cell-tip" style="color: #1E84F1;">{{version}}</text>
			</view> -->
			<!-- #endif -->
			<!-- <view class="list-cell  b-b " @click="show = true" hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">{{$t('user.name13')}}</text>
				<view class="">
					<text class="cell-tip"
						style="color: #1D93FF;">{{_i18n.locale == 'zh' ? this.$t('lang.zh') :this.$t('lang.en')}}</text>
					<text class="cell-more yticon icon-you"></text>
				</view>
			</view> -->
			<view class="list-cell  b-b"
				@click="navTo(`/pageB/noticeList/noticeInfo?name=${$t('user.name14')}&type=15`)"
				hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">{{$t('user.name14')}}</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
			<view class="list-cell  b-b"
				@click="navTo(`/pageB/noticeList/noticeInfo?name=${$t('user.name15')}&type=16`)"
				hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">{{$t('user.name15')}}</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
			<!-- <view class="list-cell   b-b " @click="navTo('cancellation')" hover-class="cell-hover"
				:hover-stay-time="50">
				<text class="cell-tit">注销账号</text>
				<text class="cell-more yticon icon-you"></text>
			</view> -->
			<view class="list-cell   b-b " @click="navTo('./changeUser')" hover-class="cell-hover"
				:hover-stay-time="50">
				<text class="cell-tit">{{$t('user.name16')}}</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
			<!-- <view class="bq">
			<view>Copyright©2022-2032</view>
			<view>云算能firetigercloud.com版权所有</view>
		</view> -->
			<view class="quit-login" @click="toLogout">
				<text>{{$t('user.name17')}}</text>
			</view>
		</view>
		<u-popup :show="show" @close="show = false" mode="center" round="10" bgColor="rgba(75, 75, 75, 0.5)">
			<view class="lang" style="width: 500rpx;height: 400rpx;color: #fff;text-align: center;">
				<view class="title">{{$t('lang.togger')}}</view>
				<view :class="['item',_i18n.locale == 'zh'?'active':'']" @click="setLang('zh')">{{$t('lang.zh')}}</view>
				<view :class="['item',_i18n.locale == 'en'?'active':'']" @click="setLang('en')">{{$t('lang.en')}}</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		mapMutations
	} from 'vuex';
	import enLocale from "@/common/locales/en.js";
	import zhLocale from "@/common/locales/zh.js";
	export default {
		data() {
			return {
				userInfo: {},
				version: '',
				show: false
			};
		},
		onShow() {
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, async (inf) => {
				this.version = 'V' + inf.version
			})
			// #endif
			this.getInfo()
			uni.setNavigationBarTitle({
				title: this.$t('user.name23')
			})
		},
		methods: {
			...mapMutations(['logout']),
			setLang(val) {
				if (this._i18n.locale == val) return
				// 切换为英文
				this._i18n.locale = val
				uni.setStorageSync('language', val)
				uni.setLocale(val)
				// const  message = this._i18n.locale === 'en' ? enLocale : zhLocale
				// this._i18n.setLocaleMessage(val,message)   //无感刷新
				this.show = false
				this.$fun.msg(this.$t('user.name22'))
				uni.setNavigationBarTitle({
					title: this.$t('user.name23')
				})
			},
			account_change() {
				uni.navigateTo({
					url: '/pages/changeAccount/changeAccount'
				})
			},
			navTo(url) {
				if (url == 'cancellation') {
					uni.showModal({
						content: this.$t('user.name18'),
						success: (e) => {
							if (e.confirm) {
								this.$fun.msg(this.$t('user.name19'))
								uni.clearStorage()
								setTimeout(() => {
									uni.reLaunch({
										url: '/pageA/public/login'
									})
								}, 200)
							}
						}
					});
					return
				}
				if (url == 'wx') {
					location.href = this.$wxLogin
				}
				uni.navigateTo({
					url
				})
			},
			//重新获取用户信息
			getInfo() {
				this.$fun.ajax.post('user/index', {}).then(res => {
					this.userInfo = res.data
					this.balance = res.data.balance
				})
			},
			//退出登录
			toLogout() {
				uni.showModal({
					content: this.$t('user.name20'),
					success: (e) => {
						if (e.confirm) {
							this.$fun.msg(this.$t('user.name21'))
							uni.clearStorage()
							setTimeout(() => {
								uni.reLaunch({
									url: '/pageA/public/login'
								})
							}, 200)
						}
					}
				});
			},
			//switch
			switchChange(e) {
				let statusTip = e.detail.value ? '打开' : '关闭';
				this.$api.msg(`${statusTip}消息推送`);
			},

		}
	}
</script>

<style lang='scss'>
	.lang {
		.title {
			font-size: 34rpx;
			font-weight: 600;
			margin: 30rpx 0 50rpx 0;
		}

		.item {
			font-size: 30rpx;
			height: 100rpx;
			line-height: 100rpx;
		}

		.active {
			background-color: rgb(48, 158, 248);
			font-weight: 600;
		}
	}

	.container-set {
		position: relative;
		height: 100%;

		.bgc {
			height: 100%;
		}
	}

	.main {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		// padding: 30rpx;
	}

	.account_change {
		width: 100%;
		text-align: center;
		position: absolute;
		bottom: 50rpx;
		left: 0;
		right: 0;
		margin: auto;
		color: rgb(0, 122, 255);
	}

	page {
		height: 100%;
	}

	.list-cell {
		display: flex;
		align-items: baseline;
		padding: 20upx 32upx;
		line-height: 60upx;
		position: relative;
		/* background: #fff; */
		justify-content: center;

		&.log-out-btn {
			margin-top: 40upx;

			.cell-tit {
				color: #fff;
				text-align: center;
				margin-right: 0;
				font-size: 20rpx;
			}
		}

		&.cell-hover {
			/* background: #fafafa; */
		}

		&.b-b:after {
			left: 30upx;
		}

		&.m-t {
			margin-top: 16upx;
		}

		.cell-more {
			align-self: baseline;
			font-size: 26upx;
			color: #fff;
			margin-left: 10upx;
		}

		.cell-tit {
			flex: 1;
			font-size: 30rpx;
			color: #fff;
			margin-right: 10upx;
		}

		.cell-tip {
			font-size: 30rpx;
			color: #333333;
			margin-right: 10upx;
		}

		switch {
			transform: translateX(16upx) scale(.84);
		}
	}

	.bq {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 170rpx;
		margin: auto;

		view {
			text-align: center;
		}
	}

	/* 退出登录 */
	.quit-login {
		position: fixed;
		left: 50rpx;
		right: 50rpx;
		bottom: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100rpx;
		background: #ff424c;
		border-radius: 20rpx;

		text {
			color: #fff;
			font-size: 30rpx;
			font-weight: 600;
		}
	}
</style>